package test.desktop;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
public class MainWindow extends JPanel implements ActionListener{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public MainWindow() {
		setLayout(new BorderLayout());
	}
	
	public static void createAndShowGUI() {
		//For windows look and feel
		try {
			UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
		}catch(Exception e) {
			UIManager.getLookAndFeelDefaults();
		}
		
		//Main window of the Application
		JFrame mainFrame = new JFrame("This is Test frame");
		mainFrame.setSize(800, 500);
		mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//mainFrame.setMinimumSize(new Dimension(150, 150));
		//test button
		JButton test_btn1 = new JButton("Test1");
		JButton test_btn2 = new JButton("Test2");
		JButton test_btn3 = new JButton("Test3");
		JButton test_btn4 = new JButton("Test4");
		
		JButton test_btn5 = new JButton("Test5");
		JButton test_btn6 = new JButton("Test6");
		JButton test_btn7 = new JButton("Test7");
		JButton test_btn8 = new JButton("Test8");
		
		//panel
		JPanel panel = new JPanel();
		
		JPanel btn_panel = new JPanel();
		btn_panel.add(test_btn1, BorderLayout.NORTH);
		btn_panel.add(test_btn2, BorderLayout.NORTH);
		btn_panel.add(test_btn3, BorderLayout.NORTH);
		btn_panel.add(test_btn4, BorderLayout.NORTH);
		btn_panel.setBorder(BorderFactory.createTitledBorder("Buttons1"));
		
		JPanel btn_panel1 = new JPanel();
		btn_panel1.add(test_btn5, BorderLayout.SOUTH);
		btn_panel1.add(test_btn6, BorderLayout.SOUTH);
		btn_panel1.add(test_btn7, BorderLayout.SOUTH);
		btn_panel1.add(test_btn8, BorderLayout.SOUTH);
		btn_panel1.setBorder(BorderFactory.createTitledBorder("Buttons2"));
		
		panel.add(btn_panel1,BorderLayout.SOUTH);
		panel.add(btn_panel,BorderLayout.SOUTH);
		
		//scrolling for the panel
		JScrollPane scrollBar = new JScrollPane(panel,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);  
		//scrollBar.add(btn_panel,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
		mainFrame.add(scrollBar);
		mainFrame.setVisible(true);
	}
	
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			
			@Override
			public void run() {
				// TODO Auto-generated method stub
				createAndShowGUI();
			}
		});
		//UIManager.
	}

	@Override
	public void actionPerformed(ActionEvent arg0) {
		// TODO Auto-generated method stub
		
	}
}
